<template>
  <el-dialog :title="'订单详情'" :close-on-click-modal="false" :visible.sync="visible">
    <el-form
      :model="dataForm"
      ref="dataForm"
      @keyup.enter.native="dataFormSubmit()"
      label-width="80px"
    >
      <el-row>
        <el-col
          style="margin:2% 4% 2% 4%"
          :span="10"
          v-for="(o,index) in dataList"
          :key="o"
          :offset="index%2==0?1:2"
        >
          <el-badge :value="o.produceQuantity" class="item">
            <el-card :body-style="{ padding: '2px' }">
              <img :src="o.produceIcon" class="image" />
              <div style="padding: 14px; width:100%">
                <span>【{{o.produceName}}】</span>
                <span align="right">{{o.producePrice}}￥/件</span>
              </div>
            </el-card>
          </el-badge>
        </el-col>
      </el-row>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import SingleUpload from "@/components/upload/singleUpload";
export default {
  components: { SingleUpload },
  data() {
    return {
      currentDate: new Date(),

      visible: false,
      dataForm: {
        key: "",
      },
      dataList: [],
      dataListLoading: false,
      orderId: 0,
    };
  },
  methods: {
    init(id) {
      (this.orderId = id), (this.dataForm.orderId = id || 0);
      this.visible = true;
      this.$http
        .get(
          `${process.env.URL_HEAD}/order/orderdetail/listByOrderId/${
            id ? id : 0
          }`,
          {
            withCredentials: true,
          }
          // params: {
          //   page: this.pageIndex,
          //   limit: this.pageSize,
          //   key: this.dataForm.key,
          // },
        )
        .then(({ data }) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list;
            console.log(data.page.list);
            // this.totalPage = data.page.totalCount;
          } else {
            this.dataList = [];
            // this.totalPage = 0;
          }
          this.dataListLoading = false;
        });
    },
    // 表单提交
    dataFormSubmit() {
      // this.$message({
      //   message: "操作成功",
      //   type: "success",
      //   duration: 1500,
      //   onClose: () => {
      //     this.visible = false;
      //     this.$emit("refreshDataList");
      //   },
      // });
      this.visible = false;
      this.$emit("refreshDataList");
    },
  },
};
</script>
<style>
.time {
  font-size: 13px;
  color: #999;
}

.bottom {
  margin-top: 13px;
  line-height: 12px;
}

.button {
  padding: 0;
  float: right;
}

.image {
  margin: 10%;
  width: 80%;
  display: block;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both;
}
</style>
